<%@ page contentType="application/xhtml+xml;charset=utf-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="stripes" uri="http://stripes.sourceforge.net/stripes.tld"%>

<!--
${view}
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
${calendar}
<br/>
${applicationScope.calendar}-->

<c:out value="Monthly view for ${year}/${month}"/><br/><br/>

<c:set var="y" value="${month}"/>
<c:if test="${y==1}"><c:set var="month" value="0${y}"/></c:if>
<c:if test="${y==2}"><c:set var="month" value="0${y}"/></c:if>
<c:if test="${y==3}"><c:set var="month" value="0${y}"/></c:if>
<c:if test="${y==4}"><c:set var="month" value="0${y}"/></c:if>
<c:if test="${y==5}"><c:set var="month" value="0${y}"/></c:if>
<c:if test="${y==6}"><c:set var="month" value="0${y}"/></c:if>
<c:if test="${y==7}"><c:set var="month" value="0${y}"/></c:if>
<c:if test="${y==8}"><c:set var="month" value="0${y}"/></c:if>
<c:if test="${y==9}"><c:set var="month" value="0${y}"/></c:if>

<table id="calendar" border="1" cellspacing="5" cellpadding="3">
    <thead>
        <tr>
            <th>
                <c:out value="Days"/>
            </th>
            <th>
                <c:out value="Total"/>
            </th>
            <c:forEach var="toolbox" items="${newKeysList}">
                <th>
                    <c:out value="${toolbox}"/>
                </th>
            </c:forEach>
        </tr>
    </thead>
    <tbody>
        <c:forEach var="date" begin="1" end="${maxDate}">
            <c:set var="d" value="${date}"/>
            <c:if test="${d==1}"><c:set var="d" value="0${d}"/></c:if>
            <c:if test="${d==2}"><c:set var="d" value="0${d}"/></c:if>
            <c:if test="${d==3}"><c:set var="d" value="0${d}"/></c:if>
            <c:if test="${d==4}"><c:set var="d" value="0${d}"/></c:if>
            <c:if test="${d==5}"><c:set var="d" value="0${d}"/></c:if>
            <c:if test="${d==6}"><c:set var="d" value="0${d}"/></c:if>
            <c:if test="${d==7}"><c:set var="d" value="0${d}"/></c:if>
            <c:if test="${d==8}"><c:set var="d" value="0${d}"/></c:if>
            <c:if test="${d==9}"><c:set var="d" value="0${d}"/></c:if>
            <c:forEach var="coll" begin="1" end="${tableColls}">
                <c:if test="${coll mod tableColls == 1}">
                    <tr>
                        <td>
                            <c:out value="${date}"/>
                        </td>
                    </c:if>
                    <c:if test="${tableColls gt 2}">
                        <c:if test="${coll mod tableColls == 2}">
                            <c:set var="totalPos" value="${year}${month}${d}"/>
                            <td>
                                <c:out value="${view[totalPos]}"/>
                            </td>
                        </c:if>
                    </c:if>
                    <c:if test="${coll ge 3}">
                        <c:set var="toolbox" value="${newKeysList[coll-3]}"/>
                        <c:set var="pos" value="${year}${month}${d};${toolbox}"/>
                        <!--<c:set var="val" value="${view[pos]}"/>-->
                        <td>
                            <c:out value="${calendar[pos]}"/>
                        </td>
                    </c:if>
                    <c:if test="${coll mod tableColls == 0}">
                        <c:if test="${tableColls eq 2}">
                            <c:set var="totalPos" value="${year}${month}${d}"/>
                            <td>
                                <c:out value="${view[totalPos]}"/>
                            </td>
                        </c:if>
                    </tr>
                </c:if>
            </c:forEach>
        </c:forEach>
    </tbody>
</table>